import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
Vue.use(ElementUI);
import axios from "axios";
Vue.prototype.$http = axios;
axios.defaults.baseURL = "https://www.liulongbin.top:8888/api/private/v1/";
import VueQuillEditor from "vue-quill-editor";
// require styles
import "quill/dist/quill.core.css";
import "quill/dist/quill.snow.css";
import "quill/dist/quill.bubble.css";
Vue.use(VueQuillEditor);
// 引入base.css
import "./assets/css/base.css";
Vue.config.productionTip = false;
// 导入树形表格组件
import TreeTable from "vue-table-with-tree-grid";
// 全局注册 树形表格
Vue.component("tree-table", TreeTable);

// 添加了一个请求拦截器
// 如果是请求拦截器 所有经过axios发起的请求都要经过拦截器的拦截
axios.interceptors.request.use(
  function(config) {
    // Do something before request is sent
    // console.log(config.headers);
    // 因为除了登录 其他都需要授权 因此在发起请求的时候 自动让拦截器拦截该请求 并且在该请求身上添加一个请求头字段
    // 字段名: Authorization
    // 字段值: token值
    config.headers.Authorization = window.sessionStorage.getItem("token");
    return config;
  },
  function(error) {
    // Do something with request error
    return Promise.reject(error);
  }
);

new Vue({
  router,
  render: h => h(App)
}).$mount("#app");
